package com.aaa.sbms.service;

import com.aaa.sbms.dao.TrainResultDao;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * @FileName:EResultServiceImpl
 * @Description:
 * @Author :99728
 * @Date: 2020/6/18 17:29
 * @Version:1.0.0
 */
@Service
public class TrainResultServiceImpl implements TrainResultService {
    @Autowired(required = false)
    private TrainResultDao trainResultDao;

    @Override
    public Map getPage(Map map) {
        //获取去输入值，计算后放入参数
        map.put("begin",(Integer.valueOf(map.get("pageNo")+"")-1)*Integer.valueOf(map.get("pageSize")+""));
        int pageSize = Integer.valueOf(map.get("pageSize").toString());
        map.put("pageSize",pageSize);
        //调用dao获取数据
        List<Map> page = trainResultDao.getPage(map);
        int total = trainResultDao.getPageCount(map);
        HashMap resultMap = new HashMap();
        resultMap.put("page",page);
        resultMap.put("total",total);
        return resultMap;
    }

    @Override
    public Map onelist(int userid) {
        Map onelist = trainResultDao.onelist(userid);
        HashMap<Object, Object> resultMap = new HashMap<>();
        resultMap.put("list",onelist);
        return resultMap;
    }

    @Override
    public int update(Map map) {
        int examgrad =  Integer.valueOf(map.get("examgrad").toString());
        trainResultDao.update(map);
        trainResultDao.updateA(map);
        return 1;
    }


}
